import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import postcssPxToViewport8plugin from 'postcss-px-to-viewport-8-plugin';

function resolve(dir) {
  return path.join(__dirname, dir);
}
// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
      // dts: false
    })
  ],
  resolve: {
    alias: {
      "@": resolve("./src"),
      '@assets': resolve('./src/assets'),
      '@components': resolve('./src/components'),
      '@views': resolve('./src/views'),
      '@utils': resolve('./src/utils'),
    },
  },
  server: {
    host: "loaclhost",
    port: 8888,
    proxy: {
      '/common': {
        // target: "http://localhost:8686",
        target: "http://124.222.219.48:8686",
        changeOrigin: true,
      },
    }
  },
  css: {
    postcss: {
      plugins: [
        postcssPxToViewport8plugin({
          unitToConvert: "px",
          viewportWidth: 375
        })
      ]
    },
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      }
    }
  }
})
